package com.icbc.dccsh.logpumper;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;

import com.icbc.dccsh.reader.RedisReader;
import com.icbc.dccsh.writter.KafkaWritter;

import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

public class Core {
	public void start() {
		try {
			LinkedBlockingQueue<String> queue = new LinkedBlockingQueue<String>();
			
			RedisReader reader = new RedisReader(queue);
			reader.parseConfig();
			reader.initialize();
			
			KafkaWritter writter = new KafkaWritter(queue);
			writter.parseConfig();
			writter.initialize();

			List<Thread> threadList = new ArrayList<Thread>();
			threadList.add(reader);
			threadList.add(writter);

			reader.start();
			writter.start();

			for (Thread t : threadList) {
				t.join();
			}
		} catch (Exception ex) {
			System.out.println(ex.toString());
		}
	}
}
